

exports.install = (Vue, options) => {

    /* 时间戳转时间格式*/
    Vue.prototype.timestampToTime = (timestamp)=> {
        if (timestamp) {
            let date = new Date(timestamp);
            let Y = date.getFullYear() + '-';
            let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
            let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
            let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
            let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
            return timestamp ? Y + M + D + h + m + '00' : '';
        } else {
            return '';
        }
    };

    /*
    * table
    * 表格统一样式
    * */

    /* 表格的样式隔行颜色 */
    Vue.prototype.getRowClass = ({row, column, rowIndex, columnIndex})=> {
        if (rowIndex == 0) {
            return 'background:#EFEFEF;color:#000;box-shadow: 2px 0px 0px 2px #999;'
        } else {
            return ''
        }
    };

    /* 表格的时间格式*/
    Vue.prototype.formatTimestampToTime = (row, column, cellValue, index)=> {
        return cellValue ? this.timestampToTime(cellValue) : '';
    };


    /* 表格的时间格式*/
    Vue.prototype.formatDate = (row, column, cellValue, index)=> {
        return cellValue ? cellValue.substr(0,10) : '';
    };



    /* 表格的详细地址*/
    Vue.prototype.formatAddress = (row, column, cellValue, index)=> {
        let sheng = row.addressSheng ? row.addressSheng : '';
        let shi = row.addressShi ? row.addressShi : '';
        let quxian = row.addressQuxian ? row.addressQuxian : '';
        let value = cellValue ? cellValue : '';
        return sheng + shi + quxian + value;
    };

    /* 表格中是否需要审核 */
    Vue.prototype.formatNeedTrain = (row, column, cellValue, index)=> {
        return cellValue == 0 ? '否' : (cellValue == 1 ? '是' : "");
    };

    /* 表格中是否需要审核 */
    Vue.prototype.formatNeed2Train = (row, column, cellValue, index)=> {
        return cellValue == 0 ? '未完成' : (cellValue == 1 ? '完成' : "");
    };

    /* 表格中是否为null */
    Vue.prototype.formatIsNull =  (row, column, cellValue, index)=> {
        return cellValue ? cellValue : '';
    };
    /* 表格中男女 */
    Vue.prototype.formatSex =  (row, column, cellValue, index)=> {
        return cellValue == 1 ? '男' : (cellValue == 2 ? '女' : '');
    };

    /* 表格中物料状态*/
    Vue.prototype.formatterMaterialState =  (row, column, cellValue, index)=> {
        return (cellValue == -1 ? '报废' : (cellValue == 0 ? '返修' : (cellValue == 1 ? '正常使用' : '')));
    };

    /* 表格中时间显示undefined */
    Vue.prototype.formatterdDete = (row, column, cellValue, index)=> {
        return cellValue ? cellValue : "";
    };





    /*
    * editor
    * 富文本
    * */
    Vue.prototype.onEditorFocus = (event)=> {
        event.enable(false);
    };

    /*
    * page
    * 分页
    * */
    Vue.prototype.handleSizeChange = (size)=> {
        this.pagesize = size;
    };
    Vue.prototype.handleCurrentChange = (currentPage)=> {
        this.currentPage = currentPage;
    };

    /*
    * 打印
    * */
    Vue.prototype.PrintData = ()=> {
        let printHtml = document.getElementById("printData").innerHTML;
        let wind = window.open("", 'newwindow', 'height=2000, width=2000, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');
        wind.document.body.innerHTML = printHtml;
        wind.print();
        wind.window.document.body.innerHTML = '';
    };


};
